#!/bin/sh

if [ ! -d "${DASD}" ]
then
    echo "Did you set up the enviroment? Try 'source env.sh'"
    exit 1
fi

#
# Run CTSS Salvager.
#
# Usage: salvagectss [s709options] [device assignments]

touch ${TMP}/cmd.txt
make-cmd-card
CMD_CBN=${TMP}/cmd.cbn

#
# Run CTSS Salvager image
#
s709 $2 -C8 -mCTSS -c${CMD}/salvagectss.cmd r=${TMP}/cmd p=${TMP}/print \
	a1r=${TAPE}/salv4.tap a3=${TMP}/salvage.bcd a9=${TMP}/trace.bin $3 $4 $5 $6 $7 \
	cd00=${DASD}/DISK1.BIN cn01=${DASD}/DRUM1.BIN cd42=${DASD}/DISK2.BIN \
	gh00=${DASD}/DRUM2.BIN gh01=${DASD}/DRUM3.BIN

bcd2txt -p ${TMP}/salvage.bcd ${OUTPUT}/salvage.lst
rm -f ${TMP}/cmd.txt ${TMP}/cmd.bcd ${TMP}/cmd.cbn ${TMP}/print.bcd ${TMP}/salvage.bcd ${TMP}/trace.bin
mv printlog.lst ${OUTPUT}
